package com.ego.common.vo.es;

import com.ego.common.to.SkuEsTo;
import lombok.Getter;
import lombok.Setter;

import java.util.ArrayList;
import java.util.List;

/**
 * @program: ego
 * @description: 搜索结果
 * @author: KamTang
 * @create: 2022-12-02 16:43
 **/
@Setter
@Getter
public class SearchResult {

    /**
     * 查询到所有商品信息
     */
    private List<SkuEsTo> skus;

    /**
     * 当前页
     */
    private Integer pageNum;

    /**
     * 总记录数
     */
    private Integer total;

    /**
     * 总页码
     */
    private Integer totalPage;

    /**
     * 当前查询到的结果，所有涉及到的品牌
     */
    private List<BrandVo> brandVos;

    /**
     * 当前查询到的结果，所有涉及到的分类
     */
    private List<CategoryVo> categoryVos = new ArrayList<>();

    /**
     * 当前查询到的结果，所有涉及到的属性
     */
    private List<AttrVo> attrVos;

    /**
     * 可遍历的导航页
     */
    private List<Integer> pageNavs;

    /*以上是返回给页面的全部数据，以下是用于前端方便筛选时展示*/

    /**
     * 面包屑导航数据
     */
    private List<NavVo> navs = new ArrayList<>();

    /**
     * 已经选择的属性ID
     */
    private List<Long> selectedAttr = new ArrayList<>();


    @Setter
    @Getter
    public static class NavVo {
        private String navName;
        private String navValue;
        private String url;

        public void build(String name, String value, String url) {
            this.setNavName(name);
            this.setNavValue(value);
            this.setUrl(url);
        }
    }

    @Setter
    @Getter
    public static class BrandVo {
        private Long brandId;
        private String brandName;
        private String brandImg;

        public BrandVo build(Long brandId, String brandName, String brandImg) {
            BrandVo brandVo = new BrandVo();
            brandVo.setBrandId(brandId);
            brandVo.setBrandName(brandName);
            brandVo.setBrandImg(brandImg);
            return brandVo;
        }
    }

    @Setter
    @Getter
    public static class CategoryVo {
        private Long categoryId;
        private String categoryName;

        public CategoryVo build(Long categoryId, String categoryName) {
            CategoryVo categoryVo = new CategoryVo();
            categoryVo.setCategoryId(categoryId);
            categoryVo.setCategoryName(categoryName);
            return categoryVo;
        }
    }

    @Setter
    @Getter
    public static class AttrVo {
        private Long attrId;
        private String attrName;
        private List<String> attrValues;

        public AttrVo build(Long attrId, String attrName, List<String> attrValues) {
            AttrVo attrVo = new AttrVo();
            attrVo.setAttrId(attrId);
            attrVo.setAttrName(attrName);
            attrVo.setAttrValues(attrValues);
            return attrVo;
        }
    }

}
